package com.nbsaas.boot.product.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.math.BigDecimal;
import java.util.Date;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "商品", model = "商品")
@Entity
@Table(name = "bs_product")
@Comment("商品表")
public class Product extends AbstractEntity {

    @Comment("商品名称")
    @SearchItem(name = "name", key = "name", label = "商品名称")
    @FormField(title = "商品名称", sortNum = "1", grid = true, required = true)
    @Column(length = 200, nullable = false)
    private String name;

    @Comment("商品副标题")
    @FormField(title = "商品副标题", sortNum = "2", grid = true)
    @Column(length = 500)
    private String subtitle;

    @Comment("商品编码")
    @SearchItem(name = "code", key = "code", label = "商品编码")
    @FormField(title = "商品编码", sortNum = "3", grid = true)
    @Column(length = 50, unique = true)
    private String code;

    @Comment("商品分类ID")
    @FormField(title = "商品分类", sortNum = "4", grid = true, type = InputType.select)
    private Long categoryId;

    @Comment("品牌ID")
    @FormField(title = "品牌", sortNum = "5", grid = true, type = InputType.select)
    private Long brandId;

    @Comment("商品主图")
    @FormField(title = "商品主图", sortNum = "6", type = InputType.image)
    @Column(length = 500)
    private String mainImage;

    @Comment("商品价格")
    @FormField(title = "商品价格", sortNum = "7", grid = true, type = InputType.el_input_number, sort = true)
    @Column(precision = 10, scale = 2)
    private BigDecimal price;

    @Comment("市场价")
    @FormField(title = "市场价", sortNum = "8", grid = true, type = InputType.el_input_number)
    @Column(precision = 10, scale = 2)
    private BigDecimal marketPrice;

    @Comment("成本价")
    @FormField(title = "成本价", sortNum = "9", grid = true, type = InputType.el_input_number)
    @Column(precision = 10, scale = 2)
    private BigDecimal costPrice;

    @Comment("库存数量")
    @FormField(title = "库存数量", sortNum = "10", grid = true, type = InputType.el_input_number, sort = true)
    private Integer stock;

    @Comment("销量")
    @FormField(title = "销量", sortNum = "11", grid = true, type = InputType.el_input_number, sort = true)
    private Integer sales;

    @Comment("浏览量")
    @FormField(title = "浏览量", sortNum = "12", grid = true, type = InputType.el_input_number, sort = true)
    private Integer views;

    @Comment("商品状态")
    @FormField(title = "商品状态", sortNum = "13", grid = true, type = InputType.select)
    @Column(length = 20)
    private String status; // ON_SALE-上架, OFF_SALE-下架, DRAFT-草稿

    @Comment("商品类型")
    @FormField(title = "商品类型", sortNum = "14", grid = true, type = InputType.select)
    @Column(length = 20)
    private String type; // NORMAL-普通商品, VIRTUAL-虚拟商品, GIFT-赠品

    @Comment("重量(克)")
    @FormField(title = "重量(克)", sortNum = "15", grid = true, type = InputType.el_input_number)
    private Integer weight;

    @Comment("体积(立方厘米)")
    @FormField(title = "体积(立方厘米)", sortNum = "16", grid = true, type = InputType.el_input_number)
    private Integer volume;

    @Comment("商品详情")
    @FormField(title = "商品详情", sortNum = "17", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String description;

    @Comment("商品参数")
    @FormField(title = "商品参数", sortNum = "18", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String parameters;

    @Comment("上架时间")
    @FormField(title = "上架时间", sortNum = "19", type = InputType.date, grid = true)
    private Date onSaleTime;

    @Comment("下架时间")
    @FormField(title = "下架时间", sortNum = "20", type = InputType.date, grid = true)
    private Date offSaleTime;

    @Comment("排序")
    @FormField(title = "排序", sortNum = "21", grid = true, type = InputType.el_input_number, sort = true)
    private Integer sort;

    @Comment("是否推荐")
    @FormField(title = "是否推荐", sortNum = "22", grid = true, type = InputType.select)
    private Boolean recommended;

    @Comment("是否热销")
    @FormField(title = "是否热销", sortNum = "23", grid = true, type = InputType.select)
    private Boolean hot;

    @Comment("是否新品")
    @FormField(title = "是否新品", sortNum = "24", grid = true, type = InputType.select)
    private Boolean newProduct;

    @Comment("SEO标题")
    @FormField(title = "SEO标题", sortNum = "25")
    @Column(length = 200)
    private String seoTitle;

    @Comment("SEO关键词")
    @FormField(title = "SEO关键词", sortNum = "26")
    @Column(length = 500)
    private String seoKeywords;

    @Comment("SEO描述")
    @FormField(title = "SEO描述", sortNum = "27")
    @Column(length = 1000)
    private String seoDescription;
} 